package com.sxj.corejava.code08_常用类.泛型;

/**
 * @author 石小俊
 */
public class Test03 {

    public static void main(String[] args) {
        Student<Integer> student = new Student<>();
        student.setNo(1);
        System.out.println(test(student));

        Student<String> student2 = new Student<>();
        student2.setNo("wbs001");
        System.out.println(test(student2));
        System.out.println("**********************");
        test2(student);
        test2(student2);
    }

    /**
     * 泛型方法
     * 如果在方法中存在泛型,那么必须在方法中指定泛型标记,通过<泛型标记>表示
     * 且泛型标记必须在返回值类型之前指定
     * @param student
     * @return
     * @param <T>
     */
    public static <T> T test(Student<T> student){
        return student.getNo();
    }

    public static <T> void test2(Student<T> student){
        System.out.println("学号:"+student.getNo());
    }

}
